home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / gnu / standard.inf (.txt) < prev    next >
GNU Info File  |  1994-04-20  |  87KB  |  2,003 lines

  1. This is Info file standards.info, produced by Makeinfo-1.55 from the
  2. input file standards.texi.
  3. START-INFO-DIR-ENTRY
  4. * Standards: (standards).        GNU coding standards.
  5. END-INFO-DIR-ENTRY
  6.    GNU Coding Standards Copyright (C) 1992, 1993, 1994 Free Software
  7. Foundation
  8.    Permission is granted to make and distribute verbatim copies of this
  9. manual provided the copyright notice and this permission notice are
  10. preserved on all copies.
  11.    Permission is granted to copy and distribute modified versions of
  12. this manual under the conditions for verbatim copying, provided that
  13. the entire resulting derived work is distributed under the terms of a
  14. permission notice identical to this one.
  15.    Permission is granted to copy and distribute translations of this
  16. manual into another language, under the above conditions for modified
  17. versions, except that this permission notice may be stated in a
  18. translation approved by the Free Software Foundation.
  19. File: standards.info,  Node: Top,  Next: Reading Non-Free Code,  Prev: (dir),  Up: (dir)
  20. Version
  21. *******
  22.    Last updated 28 March 1994.
  23. * Menu:
  24. * Reading Non-Free Code::    Referring to Proprietary Programs
  25. * Contributions::        Accepting Contributions
  26. * Change Logs::            Recording Changes
  27. * Compatibility::        Compatibility with Other Implementations
  28. * Makefile Conventions::    Makefile Conventions
  29. * Configuration::        How Configuration Should Work
  30. * Source Language::        Using Languages Other Than C
  31. * Formatting::            Formatting Your Source Code
  32. * Comments::            Commenting Your Work
  33. * Syntactic Conventions::    Clean Use of C Constructs
  34. * Names::            Naming Variables and Functions
  35. * Using Extensions::        Using Non-standard Features
  36. * System Functions::            Portability and "standard" library functions
  37. * Semantics::            Program Behavior for All Programs
  38. * Errors::            Formatting Error Messages
  39. * Libraries::            Library Behavior
  40. * Portability::            Portability As It Applies to GNU
  41. * User Interfaces::        Standards for Command Line Interfaces
  42. * Documentation::        Documenting Programs
  43. * Releases::            Making Releases
  44. File: standards.info,  Node: Reading Non-Free Code,  Next: Contributions,  Prev: Top,  Up: Top
  45. Referring to Proprietary Programs
  46. *********************************
  47.    Don't in any circumstances refer to Unix source code for or during
  48. your work on GNU!  (Or to any other proprietary programs.)
  49.    If you have a vague recollection of the internals of a Unix program,
  50. this does not absolutely mean you can't write an imitation of it, but
  51. do try to organize the imitation internally along different lines,
  52. because this is likely to make the details of the Unix version
  53. irrelevant and dissimilar to your results.
  54.    For example, Unix utilities were generally optimized to minimize
  55. memory use; if you go for speed instead, your program will be very
  56. different.  You could keep the entire input file in core and scan it
  57. there instead of using stdio.  Use a smarter algorithm discovered more
  58. recently than the Unix program.  Eliminate use of temporary files.  Do
  59. it in one pass instead of two (we did this in the assembler).
  60.    Or, on the contrary, emphasize simplicity instead of speed.  For some
  61. applications, the speed of today's computers makes simpler algorithms
  62. adequate.
  63.    Or go for generality.  For example, Unix programs often have static
  64. tables or fixed-size strings, which make for arbitrary limits; use
  65. dynamic allocation instead.  Make sure your program handles NULs and
  66. other funny characters in the input files.  Add a programming language
  67. for extensibility and write part of the program in that language.
  68.    Or turn some parts of the program into independently usable
  69. libraries.  Or use a simple garbage collector instead of tracking
  70. precisely when to free memory, or use a new GNU facility such as
  71. obstacks.
  72. File: standards.info,  Node: Contributions,  Next: Change Logs,  Prev: Reading Non-Free Code,  Up: Top
  73. Accepting Contributions
  74. ***********************
  75.    If someone else sends you a piece of code to add to the program you
  76. are working on, we need legal papers to use it--the same sort of legal
  77. papers we will need to get from you.  *Each* significant contributor to
  78. a program must sign some sort of legal papers in order for us to have
  79. clear title to the program.  The main author alone is not enough.
  80.    So, before adding in any contributions from other people, tell us so
  81. we can arrange to get the papers.  Then wait until we tell you that we
  82. have received the signed papers, before you actually use the
  83. contribution.
  84.    This applies both before you release the program and afterward.  If
  85. you receive diffs to fix a bug, and they make significant change, we
  86. need legal papers for it.
  87.    You don't need papers for changes of a few lines here or there, since
  88. they are not significant for copyright purposes.  Also, you don't need
  89. papers if all you get from the suggestion is some ideas, not actual code
  90. which you use.  For example, if you write a different solution to the
  91. problem, you don't need to get papers.
  92.    I know this is frustrating; it's frustrating for us as well.  But if
  93. you don't wait, you are going out on a limb--for example, what if the
  94. contributor's employer won't sign a disclaimer?  You might have to take
  95. that code out again!
  96.    The very worst thing is if you forget to tell us about the other
  97. contributor.  We could be very embarrassed in court some day as a
  98. result.
  99. File: standards.info,  Node: Change Logs,  Next: Compatibility,  Prev: Contributions,  Up: Top
  100. Change Logs
  101. ***********
  102.    Keep a change log for each directory, describing the changes made to
  103. source files in that directory.  The purpose of this is so that people
  104. investigating bugs in the future will know about the changes that might
  105. have introduced the bug.  Often a new bug can be found by looking at
  106. what was recently changed.  More importantly, change logs can help
  107. eliminate conceptual inconsistencies between different parts of a
  108. program; they can give you a history of how the conflicting concepts
  109. arose.
  110.    Use the Emacs command `M-x add-change' to start a new entry in the
  111. change log.  An entry should have an asterisk, the name of the changed
  112. file, and then in parentheses the name of the changed functions,
  113. variables or whatever, followed by a colon.  Then describe the changes
  114. you made to that function or variable.
  115.    Separate unrelated entries with blank lines.  When two entries
  116. represent parts of the same change, so that they work together, then
  117. don't put blank lines between them.  Then you can omit the file name
  118. and the asterisk when successive entries are in the same file.
  119.    Here are some examples:
  120.      * register.el (insert-register): Return nil.
  121.      (jump-to-register): Likewise.
  122.      
  123.      * sort.el (sort-subr): Return nil.
  124.      
  125.      * tex-mode.el (tex-bibtex-file, tex-file, tex-region):
  126.      Restart the tex shell if process is gone or stopped.
  127.      (tex-shell-running): New function.
  128.      
  129.      * expr.c (store_one_arg): Round size up for move_block_to_reg.
  130.      (expand_call): Round up when emitting USE insns.
  131.      * stmt.c (assign_parms): Round size up for move_block_from_reg.
  132.    It's important to name the changed function or variable in full.
  133. Don't abbreviate them; don't combine them.  Subsequent maintainers will
  134. often search for a function name to find all the change log entries that
  135. pertain to it; if you abbreviate the name, they won't find it when they
  136. search.  For example, some people are tempted to abbreviate groups of
  137. function names by writing `* register.el ({insert,jump-to}-register)';
  138. this is not a good idea, since searching for `jump-to-register' or
  139. `insert-register' would not find the entry.
  140.    There's no need to describe the full purpose of the changes or how
  141. they work together.  It is better to put such explanations in comments
  142. in the code.  That's why just "New function" is enough; there is a
  143. comment with the function in the source to explain what it does.
  144.    However, sometimes it is useful to write one line to describe the
  145. overall purpose of a large batch of changes.
  146.    You can think of the change log as a conceptual "undo list" which
  147. explains how earlier versions were different from the current version.
  148. People can see the current version; they don't need the change log to
  149. tell them what is in it.  What they want from a change log is a clear
  150. explanation of how the earlier version differed.
  151.    When you change the calling sequence of a function in a simple
  152. fashion, and you change all the callers of the function, there is no
  153. need to make individual entries for all the callers.  Just write in the
  154. entry for the function being called, "All callers changed."
  155.    When you change just comments or doc strings, it is enough to write
  156. an entry for the file, without mentioning the functions.  Write just,
  157. "Doc fix."  There's no need to keep a change log for documentation
  158. files.  This is because documentation is not susceptible to bugs that
  159. are hard to fix.  Documentation does not consist of parts that must
  160. interact in a precisely engineered fashion; to correct an error, you
  161. need not know the history of the erroneous passage.
  162. File: standards.info,  Node: Compatibility,  Next: Makefile Conventions,  Prev: Change Logs,  Up: Top
  163. Compatibility with Other Implementations
  164. ****************************************
  165.    With certain exceptions, utility programs and libraries for GNU
  166. should be upward compatible with those in Berkeley Unix, and upward
  167. compatible with ANSI C if ANSI C specifies their behavior, and upward
  168. compatible with POSIX if POSIX specifies their behavior.
  169.    When these standards conflict, it is useful to offer compatibility
  170. modes for each of them.
  171.    ANSI C and POSIX prohibit many kinds of extensions.  Feel free to
  172. make the extensions anyway, and include a `--ansi' or `--compatible'
  173. option to turn them off.  However, if the extension has a significant
  174. chance of breaking any real programs or scripts, then it is not really
  175. upward compatible.  Try to redesign its interface.
  176.    Many GNU programs suppress extensions that conflict with POSIX if the
  177. environment variable `POSIXLY_CORRECT' is defined (even if it is
  178. defined with a null value).  Please make your program recognize this
  179. variable if appropriate.
  180.    When a feature is used only by users (not by programs or command
  181. files), and it is done poorly in Unix, feel free to replace it
  182. completely with something totally different and better.  (For example,
  183. vi is replaced with Emacs.)  But it is nice to offer a compatible
  184. feature as well.  (There is a free vi clone, so we offer it.)
  185.    Additional useful features not in Berkeley Unix are welcome.
  186. Additional programs with no counterpart in Unix may be useful, but our
  187. first priority is usually to duplicate what Unix already has.
  188. File: standards.info,  Node: Makefile Conventions,  Next: Configuration,  Prev: Compatibility,  Up: Top
  189. Makefile Conventions
  190. ********************
  191.    This chapter describes conventions for writing the Makefiles for GNU
  192. programs.
  193. * Menu:
  194. * Makefile Basics::
  195. * Utilities in Makefiles::
  196. * Standard Targets::
  197. * Command Variables::
  198. * Directory Variables::
  199. File: standards.info,  Node: Makefile Basics,  Next: Utilities in Makefiles,  Up: Makefile Conventions
  200. General Conventions for Makefiles
  201. =================================
  202.    Every Makefile should contain this line:
  203.      SHELL = /bin/sh
  204. to avoid trouble on systems where the `SHELL' variable might be
  205. inherited from the environment.  (This is never a problem with GNU
  206. `make'.)
  207.    Don't assume that `.' is in the path for command execution.  When
  208. you need to run programs that are a part of your package during the
  209. make, please make sure that it uses `./' if the program is built as
  210. part of the make or `$(srcdir)/' if the file is an unchanging part of
  211. the source code.  Without one of these prefixes, the current search
  212. path is used.
  213.    The distinction between `./' and `$(srcdir)/' is important when
  214. using the `--srcdir' option to `configure'.  A rule of the form:
  215.      foo.1 : foo.man sedscript
  216.              sed -e sedscript foo.man > foo.1
  217. will fail when the current directory is not the source directory,
  218. because `foo.man' and `sedscript' are not in the current directory.
  219.    When using GNU `make', relying on `VPATH' to find the source file
  220. will work in the case where there is a single dependency file, since
  221. the `make' automatic variable `$<' will represent the source file
  222. wherever it is.  (Many versions of `make' set `$<' only in implicit
  223. rules.)  A makefile target like
  224.      foo.o : bar.c
  225.              $(CC) -I. -I$(srcdir) $(CFLAGS) -c bar.c -o foo.o
  226. should instead be written as
  227.      foo.o : bar.c
  228.              $(CC) $(CFLAGS) $< -o $@
  229. in order to allow `VPATH' to work correctly.  When the target has
  230. multiple dependencies, using an explicit `$(srcdir)' is the easiest way
  231. to make the rule work well.  For example, the target above for `foo.1'
  232. is best written as:
  233.      foo.1 : foo.man sedscript
  234.              sed -s $(srcdir)/sedscript $(srcdir)/foo.man > foo.1
  235. File: standards.info,  Node: Utilities in Makefiles,  Next: Standard Targets,  Prev: Makefile Basics,  Up: Makefile Conventions
  236. Utilities in Makefiles
  237. ======================
  238.    Write the Makefile commands (and any shell scripts, such as
  239. `configure') to run in `sh', not in `csh'.  Don't use any special
  240. features of `ksh' or `bash'.
  241.    The `configure' script and the Makefile rules for building and
  242. installation should not use any utilities directly except these:
  243.      cat cmp cp echo egrep expr grep
  244.      ln mkdir mv pwd rm rmdir sed test touch
  245.    Stick to the generally supported options for these programs.  For
  246. example, don't use `mkdir -p', convenient as it may be, because most
  247. systems don't support it.
  248.    The Makefile rules for building and installation can also use
  249. compilers and related programs, but should do so via `make' variables
  250. so that the user can substitute alternatives.  Here are some of the
  251. programs we mean:
  252.      ar bison cc flex install ld lex
  253.      make makeinfo ranlib texi2dvi yacc
  254.    When you use `ranlib', you should test whether it exists, and run it
  255. only if it exists, so that the distribution will work on systems that
  256. don't have `ranlib'.
  257.    If you use symbolic links, you should implement a fallback for
  258. systems that don't have symbolic links.
  259.    It is ok to use other utilities in Makefile portions (or scripts)
  260. intended only for particular systems where you know those utilities to
  261. exist.
  262. File: standards.info,  Node: Standard Targets,  Next: Command Variables,  Prev: Utilities in Makefiles,  Up: Makefile Conventions
  263. Standard Targets for Users
  264. ==========================
  265.    All GNU programs should have the following targets in their
  266. Makefiles:
  267. `all'
  268.      Compile the entire program.  This should be the default target.
  269.      This target need not rebuild any documentation files; Info files
  270.      should normally be included in the distribution, and DVI files
  271.      should be made only when explicitly asked for.
  272. `install'
  273.      Compile the program and copy the executables, libraries, and so on
  274.      to the file names where they should reside for actual use.  If
  275.      there is a simple test to verify that a program is properly
  276.      installed, this target should run that test.
  277.      The commands should create all the directories in which files are
  278.      to be installed, if they don't already exist.  This includes the
  279.      directories specified as the values of the variables `prefix' and
  280.      `exec_prefix', as well as all subdirectories that are needed.  One
  281.      way to do this is by means of an `installdirs' target as described
  282.      below.
  283.      Use `-' before any command for installing a man page, so that
  284.      `make' will ignore any errors.  This is in case there are systems
  285.      that don't have the Unix man page documentation system installed.
  286.      The way to install Info files is to copy them into `$(infodir)'
  287.      with `$(INSTALL_DATA)' (*note Command Variables::.), and then run
  288.      the `install-info' program if it is present.  `install-info' is a
  289.      script that edits the Info `dir' file to add or update the menu
  290.      entry for the given Info file; it will be part of the Texinfo
  291.      package.  Here is a sample rule to install an Info file:
  292.           $(infodir)/foo.info: foo.info
  293.           # There may be a newer info file in . than in srcdir.
  294.                   -if test -f foo.info; then d=.; \
  295.                    else d=$(srcdir); fi; \
  296.                   $(INSTALL_DATA) $$d/foo.info $@; \
  297.           # Run install-info only if it exists.
  298.           # Use `if' instead of just prepending `-' to the
  299.           # line so we notice real errors from install-info.
  300.           # We use `$(SHELL) -c' because some shells do not
  301.           # fail gracefully when there is an unknown command.
  302.                   if $(SHELL) -c 'install-info --version' \
  303.                      >/dev/null 2>&1; then \
  304.                     install-info --infodir=$(infodir) $$d/foo.info; \
  305.                   else true; fi
  306. `uninstall'
  307.      Delete all the installed files that the `install' target would
  308.      create (but not the noninstalled files such as `make all' would
  309.      create).
  310. `clean'
  311.      Delete all files from the current directory that are normally
  312.      created by building the program.  Don't delete the files that
  313.      record the configuration.  Also preserve files that could be made
  314.      by building, but normally aren't because the distribution comes
  315.      with them.
  316.      Delete `.dvi' files here if they are not part of the distribution.
  317. `distclean'
  318.      Delete all files from the current directory that are created by
  319.      configuring or building the program.  If you have unpacked the
  320.      source and built the program without creating any other files,
  321.      `make distclean' should leave only the files that were in the
  322.      distribution.
  323. `mostlyclean'
  324.      Like `clean', but may refrain from deleting a few files that people
  325.      normally don't want to recompile.  For example, the `mostlyclean'
  326.      target for GCC does not delete `libgcc.a', because recompiling it
  327.      is rarely necessary and takes a lot of time.
  328. `realclean'
  329.      Delete everything from the current directory that can be
  330.      reconstructed with this Makefile.  This typically includes
  331.      everything deleted by `distclean', plus more: C source files
  332.      produced by Bison, tags tables, Info files, and so on.
  333.      One exception, however: `make realclean' should not delete
  334.      `configure' even if `configure' can be remade using a rule in the
  335.      Makefile.  More generally, `make realclean' should not delete
  336.      anything that needs to exist in order to run `configure' and then
  337.      begin to build the program.
  338. `TAGS'
  339.      Update a tags table for this program.
  340. `info'
  341.      Generate any Info files needed.  The best way to write the rules
  342.      is as follows:
  343.           info: foo.info
  344.           
  345.           foo.info: foo.texi chap1.texi chap2.texi
  346.                   $(MAKEINFO) $(srcdir)/foo.texi
  347.      You must define the variable `MAKEINFO' in the Makefile.  It should
  348.      run the `makeinfo' program, which is part of the Texinfo
  349.      distribution.
  350. `dvi'
  351.      Generate DVI files for all TeXinfo documentation.  For example:
  352.           dvi: foo.dvi
  353.           
  354.           foo.dvi: foo.texi chap1.texi chap2.texi
  355.                   $(TEXI2DVI) $(srcdir)/foo.texi
  356.      You must define the variable `TEXI2DVI' in the Makefile.  It should
  357.      run the program `texi2dvi', which is part of the Texinfo
  358.      distribution.  Alternatively, write just the dependencies, and
  359.      allow GNU Make to provide the command.
  360. `dist'
  361.      Create a distribution tar file for this program.  The tar file
  362.      should be set up so that the file names in the tar file start with
  363.      a subdirectory name which is the name of the package it is a
  364.      distribution for.  This name can include the version number.
  365.      For example, the distribution tar file of GCC version 1.40 unpacks
  366.      into a subdirectory named `gcc-1.40'.
  367.      The easiest way to do this is to create a subdirectory
  368.      appropriately named, use `ln' or `cp' to install the proper files
  369.      in it, and then `tar' that subdirectory.
  370.      The `dist' target should explicitly depend on all non-source files
  371.      that are in the distribution, to make sure they are up to date in
  372.      the distribution.  *Note Making Releases: (standards)Releases.
  373. `check'
  374.      Perform self-tests (if any).  The user must build the program
  375.      before running the tests, but need not install the program; you
  376.      should write the self-tests so that they work when the program is
  377.      built but not installed.
  378.    The following targets are suggested as conventional names, for
  379. programs in which they are useful.
  380. `installcheck'
  381.      Perform installation tests (if any).  The user must build and
  382.      install the program before running the tests.  You should not
  383.      assume that `$(bindir)' is in the search path.
  384. `installdirs'
  385.      It's useful to add a target named `installdirs' to create the
  386.      directories where files are installed, and their parent
  387.      directories.  There is a script called `mkinstalldirs' which is
  388.      convenient for this; find it in the Texinfo package.You can use a
  389.      rule like this:
  390.           # Make sure all installation directories (e.g. $(bindir))
  391.           # actually exist by making them if necessary.
  392.           installdirs: mkinstalldirs
  393.                   $(srcdir)/mkinstalldirs $(bindir) $(datadir) \
  394.                                           $(libdir) $(infodir) \
  395.                                           $(mandir)
  396. File: standards.info,  Node: Command Variables,  Next: Directory Variables,  Prev: Standard Targets,  Up: Makefile Conventions
  397. Variables for Specifying Commands
  398. =================================
  399.    Makefiles should provide variables for overriding certain commands,
  400. options, and so on.
  401.    In particular, you should run most utility programs via variables.
  402. Thus, if you use Bison, have a variable named `BISON' whose default
  403. value is set with `BISON = bison', and refer to it with `$(BISON)'
  404. whenever you need to use Bison.
  405.    File management utilities such as `ln', `rm', `mv', and so on, need
  406. not be referred to through variables in this way, since users don't
  407. need to replace them with other programs.
  408.    Each program-name variable should come with an options variable that
  409. is used to supply options to the program.  Append `FLAGS' to the
  410. program-name variable name to get the options variable name--for
  411. example, `BISONFLAGS'.  (The name `CFLAGS' is an exception to this
  412. rule, but we keep it because it is standard.)  Use `CPPFLAGS' in any
  413. compilation command that runs the preprocessor, and use `LDFLAGS' in
  414. any compilation command that does linking as well as in any direct use
  415. of `ld'.
  416.    If there are C compiler options that *must* be used for proper
  417. compilation of certain files, do not include them in `CFLAGS'.  Users
  418. expect to be able to specify `CFLAGS' freely themselves.  Instead,
  419. arrange to pass the necessary options to the C compiler independently
  420. of `CFLAGS', by writing them explicitly in the compilation commands or
  421. by defining an implicit rule, like this:
  422.      CFLAGS = -g
  423.      ALL_CFLAGS = -I. $(CFLAGS)
  424.      .c.o:
  425.              $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<
  426.    Do include the `-g' option in `CFLAGS', because that is not
  427. *required* for proper compilation.  You can consider it a default that
  428. is only recommended.  If the package is set up so that it is compiled
  429. with GCC by default, then you might as well include `-O' in the default
  430. value of `CFLAGS' as well.
  431.    Put `CFLAGS' last in the compilation command, after other variables
  432. containing compiler options, so the user can use `CFLAGS' to override
  433. the others.
  434.    Every Makefile should define the variable `INSTALL', which is the
  435. basic command for installing a file into the system.
  436.    Every Makefile should also define the variables `INSTALL_PROGRAM'
  437. and `INSTALL_DATA'.  (The default for each of these should be
  438. `$(INSTALL)'.)  Then it should use those variables as the commands for
  439. actual installation, for executables and nonexecutables respectively.
  440. Use these variables as follows:
  441.      $(INSTALL_PROGRAM) foo $(bindir)/foo
  442.      $(INSTALL_DATA) libfoo.a $(libdir)/libfoo.a
  443. Always use a file name, not a directory name, as the second argument of
  444. the installation commands.  Use a separate command for each file to be
  445. installed.
  446. File: standards.info,  Node: Directory Variables,  Prev: Command Variables,  Up: Makefile Conventions
  447. Variables for Installation Directories
  448. ======================================
  449.    Installation directories should always be named by variables, so it
  450. is easy to install in a nonstandard place.  The standard names for these
  451. variables are:
  452. `prefix'
  453.      A prefix used in constructing the default values of the variables
  454.      listed below.  The default value of `prefix' should be `/usr/local'
  455.      (at least for now).
  456. `exec_prefix'
  457.      A prefix used in constructing the default values of some of the
  458.      variables listed below.  The default value of `exec_prefix' should
  459.      be `$(prefix)'.
  460.      Generally, `$(exec_prefix)' is used for directories that contain
  461.      machine-specific files (such as executables and subroutine
  462.      libraries), while `$(prefix)' is used directly for other
  463.      directories.
  464. `bindir'
  465.      The directory for installing executable programs that users can
  466.      run.  This should normally be `/usr/local/bin', but write it as
  467.      `$(exec_prefix)/bin'.
  468. `libdir'
  469.      The directory for installing executable files to be run by the
  470.      program rather than by users.  Object files and libraries of
  471.      object code should also go in this directory.  The idea is that
  472.      this directory is used for files that pertain to a specific
  473.      machine architecture, but need not be in the path for commands.
  474.      The value of `libdir' should normally be `/usr/local/lib', but
  475.      write it as `$(exec_prefix)/lib'.
  476. `datadir'
  477.      The directory for installing read-only data files which the
  478.      programs refer to while they run.  This directory is used for
  479.      files which are independent of the type of machine being used.
  480.      This should normally be `/usr/local/lib', but write it as
  481.      `$(prefix)/lib'.
  482. `statedir'
  483.      The directory for installing data files which the programs modify
  484.      while they run.  These files should be independent of the type of
  485.      machine being used, and it should be possible to share them among
  486.      machines at a network installation.  This should normally be
  487.      `/usr/local/lib', but write it as `$(prefix)/lib'.
  488. `includedir'
  489.      The directory for installing header files to be included by user
  490.      programs with the C `#include' preprocessor directive.  This
  491.      should normally be `/usr/local/include', but write it as
  492.      `$(prefix)/include'.
  493.      Most compilers other than GCC do not look for header files in
  494.      `/usr/local/include'.  So installing the header files this way is
  495.      only useful with GCC.  Sometimes this is not a problem because some
  496.      libraries are only really intended to work with GCC.  But some
  497.      libraries are intended to work with other compilers.  They should
  498.      install their header files in two places, one specified by
  499.      `includedir' and one specified by `oldincludedir'.
  500. `oldincludedir'
  501.      The directory for installing `#include' header files for use with
  502.      compilers other than GCC.  This should normally be `/usr/include'.
  503.      The Makefile commands should check whether the value of
  504.      `oldincludedir' is empty.  If it is, they should not try to use
  505.      it; they should cancel the second installation of the header files.
  506.      A package should not replace an existing header in this directory
  507.      unless the header came from the same package.  Thus, if your Foo
  508.      package provides a header file `foo.h', then it should install the
  509.      header file in the `oldincludedir' directory if either (1) there
  510.      is no `foo.h' there or (2) the `foo.h' that exists came from the
  511.      Foo package.
  512.      To tell whether `foo.h' came from the Foo package, put a magic
  513.      string in the file--part of a comment--and grep for that string.
  514. `mandir'
  515.      The directory for installing the man pages (if any) for this
  516.      package.  It should include the suffix for the proper section of
  517.      the manual--usually `1' for a utility.  It will normally be
  518.      `/usr/local/man/man1', but you should write it as
  519.      `$(prefix)/man/man1'.
  520. `man1dir'
  521.      The directory for installing section 1 man pages.
  522. `man2dir'
  523.      The directory for installing section 2 man pages.
  524. `...'
  525.      Use these names instead of `mandir' if the package needs to
  526.      install man pages in more than one section of the manual.
  527.      *Don't make the primary documentation for any GNU software be a
  528.      man page.  Write a manual in Texinfo instead.  Man pages are just
  529.      for the sake of people running GNU software on Unix, which is a
  530.      secondary application only.*
  531. `manext'
  532.      The file name extension for the installed man page.  This should
  533.      contain a period followed by the appropriate digit; it should
  534.      normally be `.1'.
  535. `man1ext'
  536.      The file name extension for installed section 1 man pages.
  537. `man2ext'
  538.      The file name extension for installed section 2 man pages.
  539. `...'
  540.      Use these names instead of `manext' if the package needs to
  541.      install man pages in more than one section of the manual.
  542. `infodir'
  543.      The directory for installing the Info files for this package.  By
  544.      default, it should be `/usr/local/info', but it should be written
  545.      as `$(prefix)/info'.
  546. `srcdir'
  547.      The directory for the sources being compiled.  The value of this
  548.      variable is normally inserted by the `configure' shell script.
  549.    For example:
  550.      # Common prefix for installation directories.
  551.      # NOTE: This directory must exist when you start the install.
  552.      prefix = /usr/local
  553.      exec_prefix = $(prefix)
  554.      # Where to put the executable for the command `gcc'.
  555.      bindir = $(exec_prefix)/bin
  556.      # Where to put the directories used by the compiler.
  557.      libdir = $(exec_prefix)/lib
  558.      # Where to put the Info files.
  559.      infodir = $(prefix)/info
  560.    If your program installs a large number of files into one of the
  561. standard user-specified directories, it might be useful to group them
  562. into a subdirectory particular to that program.  If you do this, you
  563. should write the `install' rule to create these subdirectories.
  564.    Do not expect the user to include the subdirectory name in the value
  565. of any of the variables listed above.  The idea of having a uniform set
  566. of variable names for installation directories is to enable the user to
  567. specify the exact same values for several different GNU packages.  In
  568. order for this to be useful, all the packages must be designed so that
  569. they will work sensibly when the user does so.
  570. File: standards.info,  Node: Configuration,  Next: Source Language,  Prev: Makefile Conventions,  Up: Top
  571. How Configuration Should Work
  572. *****************************
  573.    Each GNU distribution should come with a shell script named
  574. `configure'.  This script is given arguments which describe the kind of
  575. machine and system you want to compile the program for.
  576.    The `configure' script must record the configuration options so that
  577. they affect compilation.
  578.    One way to do this is to make a link from a standard name such as
  579. `config.h' to the proper configuration file for the chosen system.  If
  580. you use this technique, the distribution should *not* contain a file
  581. named `config.h'.  This is so that people won't be able to build the
  582. program without configuring it first.
  583.    Another thing that `configure' can do is to edit the Makefile.  If
  584. you do this, the distribution should *not* contain a file named
  585. `Makefile'.  Instead, include a file `Makefile.in' which contains the
  586. input used for editing.  Once again, this is so that people won't be
  587. able to build the program without configuring it first.
  588.    If `configure' does write the `Makefile', then `Makefile' should
  589. have a target named `Makefile' which causes `configure' to be rerun,
  590. setting up the same configuration that was set up last time.  The files
  591. that `configure' reads should be listed as dependencies of `Makefile'.
  592.    All the files which are output from the `configure' script should
  593. have comments at the beginning explaining that they were generated
  594. automatically using `configure'.  This is so that users won't think of
  595. trying to edit them by hand.
  596.    The `configure' script should write a file named `config.status'
  597. which describes which configuration options were specified when the
  598. program was last configured.  This file should be a shell script which,
  599. if run, will recreate the same configuration.
  600.    The `configure' script should accept an option of the form
  601. `--srcdir=DIRNAME' to specify the directory where sources are found (if
  602. it is not the current directory).  This makes it possible to build the
  603. program in a separate directory, so that the actual source directory is
  604. not modified.
  605.    If the user does not specify `--srcdir', then `configure' should
  606. check both `.' and `..' to see if it can find the sources.  If it finds
  607. the sources in one of these places, it should use them from there.
  608. Otherwise, it should report that it cannot find the sources, and should
  609. exit with nonzero status.
  610.    Usually the easy way to support `--srcdir' is by editing a
  611. definition of `VPATH' into the Makefile.  Some rules may need to refer
  612. explicitly to the specified source directory.  To make this possible,
  613. `configure' can add to the Makefile a variable named `srcdir' whose
  614. value is precisely the specified directory.
  615.    The `configure' script should also take an argument which specifies
  616. the type of system to build the program for.  This argument should look
  617. like this:
  618.      CPU-COMPANY-SYSTEM
  619.    For example, a Sun 3 might be `m68k-sun-sunos4.1'.
  620.    The `configure' script needs to be able to decode all plausible
  621. alternatives for how to describe a machine.  Thus, `sun3-sunos4.1'
  622. would be a valid alias.  So would `sun3-bsd4.2', since SunOS is
  623. basically BSD and no other BSD system is used on a Sun.  For many
  624. programs, `vax-dec-ultrix' would be an alias for `vax-dec-bsd', simply
  625. because the differences between Ultrix and BSD are rarely noticeable,
  626. but a few programs might need to distinguish them.
  627.    There is a shell script called `config.sub' that you can use as a
  628. subroutine to validate system types and canonicalize aliases.
  629.    Other options are permitted to specify in more detail the software
  630. or hardware present on the machine, and include or exclude optional
  631. parts of the package:
  632. `--enable-FEATURE[=PARAMETER]'
  633.      Configure the package to build and install an optional user-level
  634.      facility called FEATURE.  This allows users to choose which
  635.      optional features to include.  Giving an optional PARAMETER of
  636.      `no' should omit FEATURE, if it is built by default.
  637.      No `--enable' option should *ever* cause one feature to replace
  638.      another.  No `--enable' option should ever substitute one useful
  639.      behavior for another useful behavior.  The only proper use for
  640.      `--enable' is for questions of whether to build part of the program
  641.      or exclude it.
  642. `--with-PACKAGE'
  643.      The package PACKAGE will be installed, so configure this package
  644.      to work with PACKAGE.
  645.      Possible values of PACKAGE include `x', `x-toolkit', `gnu-as' (or
  646.      `gas'), `gnu-ld', `gnu-libc', and `gdb'.
  647.      Do not use a `--with' option to specify the file name to use to
  648.      find certain files.  That is outside the scope of what `--with'
  649.      options are for.
  650. `--nfp'
  651.      The target machine has no floating point processor.
  652. `--gas'
  653.      The target machine assembler is GAS, the GNU assembler.  This is
  654.      obsolete; users should use `--with-gnu-as' instead.
  655. `--x'
  656.      The target machine has the X Window System installed.  This is
  657.      obsolete; users should use `--with-x' instead.
  658.    All `configure' scripts should accept all of these "detail" options,
  659. whether or not they make any difference to the particular package at
  660. hand.  In particular, they should accept any option that starts with
  661. `--with-' or `--enable-'.  This is so users will be able to configure
  662. an entire GNU source tree at once with a single set of options.
  663.    You will note that the categories `--with-' and `--enable-' are
  664. narrow: they *do not* provide a place for any sort of option you might
  665. think of.  That is deliberate.  We want to limit the possible
  666. configuration options in GNU software.  We do not want GNU programs to
  667. have idiosyncratic configuration options.
  668.    Packages that perform part of compilation may support
  669. cross-compilation.  In such a case, the host and target machines for
  670. the program may be different.  The `configure' script should normally
  671. treat the specified type of system as both the host and the target,
  672. thus producing a program which works for the same type of machine that
  673. it runs on.
  674.    The way to build a cross-compiler, cross-assembler, or what have
  675. you, is to specify the option `--host=HOSTTYPE' when running
  676. `configure'.  This specifies the host system without changing the type
  677. of target system.  The syntax for HOSTTYPE is the same as described
  678. above.
  679.    Bootstrapping a cross-compiler requires compiling it on a machine
  680. other than the host it will run on.  Compilation packages accept a
  681. configuration option `--build=HOSTTYPE' for specifying the
  682. configuration on which you will compile them, in case that is different
  683. from the host.
  684.    Programs for which cross-operation is not meaningful need not accept
  685. the `--host' option, because configuring an entire operating system for
  686. cross-operation is not a meaningful thing.
  687.    Some programs have ways of configuring themselves automatically.  If
  688. your program is set up to do this, your `configure' script can simply
  689. ignore most of its arguments.
  690. File: standards.info,  Node: Source Language,  Next: Formatting,  Prev: Configuration,  Up: Top
  691. Using Languages Other Than C
  692. ****************************
  693.    Using a language other than C is like using a non-standard feature:
  694. it will cause trouble for users.  Even if GCC supports the other
  695. language, users may find it inconvenient to have to install the
  696. compiler for that other language in order to build your program.  So
  697. please write in C.
  698.    There are three exceptions for this rule:
  699.    * It is okay to use a special language if the same program contains
  700.      an interpreter for that language.
  701.      Thus, it is not a problem that GNU Emacs contains code written in
  702.      Emacs Lisp, because it comes with a Lisp interpreter.
  703.    * It is okay to use another language in a tool specifically intended
  704.      for use with that language.
  705.      This is okay because the only people who want to build the tool
  706.      will be those who have installed the other language anyway.
  707.    * If an application is not of extremely widespread interest, then
  708.      perhaps it's not important if the application is inconvenient to
  709.      install.
  710. File: standards.info,  Node: Formatting,  Next: Comments,  Prev: Source Language,  Up: Top
  711. Formatting Your Source Code
  712. ***************************
  713.    It is important to put the open-brace that starts the body of a C
  714. function in column zero, and avoid putting any other open-brace or
  715. open-parenthesis or open-bracket in column zero.  Several tools look
  716. for open-braces in column zero to find the beginnings of C functions.
  717. These tools will not work on code not formatted that way.
  718.    It is also important for function definitions to start the name of
  719. the function in column zero.  This helps people to search for function
  720. definitions, and may also help certain tools recognize them.  Thus, the
  721. proper format is this:
  722.      static char *
  723.      concat (s1, s2)        /* Name starts in column zero here */
  724.           char *s1, *s2;
  725.      {                     /* Open brace in column zero here */
  726.        ...
  727.      }
  728. or, if you want to use ANSI C, format the definition like this:
  729.      static char *
  730.      concat (char *s1, char *s2)
  731.      {
  732.        ...
  733.      }
  734.    In ANSI C, if the arguments don't fit nicely on one line, split it
  735. like this:
  736.      int
  737.      lots_of_args (int an_integer, long a_long, short a_short,
  738.                    double a_double, float a_float)
  739.      ...
  740.    For the body of the function, we prefer code formatted like this:
  741.      if (x < foo (y, z))
  742.        haha = bar[4] + 5;
  743.      else
  744.        {
  745.          while (z)
  746.            {
  747.              haha += foo (z, z);
  748.              z--;
  749.            }
  750.          return ++x + bar ();
  751.        }
  752.    We find it easier to read a program when it has spaces before the
  753. open-parentheses and after the commas.  Especially after the commas.
  754.    When you split an expression into multiple lines, split it before an
  755. operator, not after one.  Here is the right way:
  756.      if (foo_this_is_long && bar > win (x, y, z)
  757.          && remaining_condition)
  758.    Try to avoid having two operators of different precedence at the same
  759. level of indentation.  For example, don't write this:
  760.      mode = (inmode[j] == VOIDmode
  761.              || GET_MODE_SIZE (outmode[j]) > GET_MODE_SIZE (inmode[j])
  762.              ? outmode[j] : inmode[j]);
  763.    Instead, use extra parentheses so that the indentation shows the
  764. nesting:
  765.      mode = ((inmode[j] == VOIDmode
  766.               || (GET_MODE_SIZE (outmode[j]) > GET_MODE_SIZE (inmode[j])))
  767.              ? outmode[j] : inmode[j]);
  768.    Insert extra parentheses so that Emacs will indent the code properly.
  769. For example, the following indentation looks nice if you do it by hand,
  770. but Emacs would mess it up:
  771.      v = rup->ru_utime.tv_sec*1000 + rup->ru_utime.tv_usec/1000
  772.          + rup->ru_stime.tv_sec*1000 + rup->ru_stime.tv_usec/1000;
  773.    But adding a set of parentheses solves the problem:
  774.      v = (rup->ru_utime.tv_sec*1000 + rup->ru_utime.tv_usec/1000
  775.           + rup->ru_stime.tv_sec*1000 + rup->ru_stime.tv_usec/1000);
  776.    Format do-while statements like this:
  777.      do
  778.        {
  779.          a = foo (a);
  780.        }
  781.      while (a > 0);
  782.    Please use formfeed characters (control-L) to divide the program into
  783. pages at logical places (but not within a function).  It does not matter
  784. just how long the pages are, since they do not have to fit on a printed
  785. page.  The formfeeds should appear alone on lines by themselves.
  786. File: standards.info,  Node: Comments,  Next: Syntactic Conventions,  Prev: Formatting,  Up: Top
  787. Commenting Your Work
  788. ********************
  789.    Every program should start with a comment saying briefly what it is
  790. for.  Example: `fmt - filter for simple filling of text'.
  791.    Please put a comment on each function saying what the function does,
  792. what sorts of arguments it gets, and what the possible values of
  793. arguments mean and are used for.  It is not necessary to duplicate in
  794. words the meaning of the C argument declarations, if a C type is being
  795. used in its customary fashion.  If there is anything nonstandard about
  796. its use (such as an argument of type `char *' which is really the
  797. address of the second character of a string, not the first), or any
  798. possible values that would not work the way one would expect (such as,
  799. that strings containing newlines are not guaranteed to work), be sure
  800. to say so.
  801.    Also explain the significance of the return value, if there is one.
  802.    Please put two spaces after the end of a sentence in your comments,
  803. so that the Emacs sentence commands will work.  Also, please write
  804. complete sentences and capitalize the first word.  If a lower-case
  805. identifer comes at the beginning of a sentence, don't capitalize it!
  806. Changing the spelling makes it a different identifier.  If you don't
  807. like starting a sentence with a lower case letter, write the sentence
  808. differently (e.g., "The identifier lower-case is ...").
  809.    The comment on a function is much clearer if you use the argument
  810. names to speak about the argument values.  The variable name itself
  811. should be lower case, but write it in upper case when you are speaking
  812. about the value rather than the variable itself.  Thus, "the inode
  813. number NODE_NUM" rather than "an inode".
  814.    There is usually no purpose in restating the name of the function in
  815. the comment before it, because the reader can see that for himself.
  816. There might be an exception when the comment is so long that the
  817. function itself would be off the bottom of the screen.
  818.    There should be a comment on each static variable as well, like this:
  819.      /* Nonzero means truncate lines in the display;
  820.         zero means continue them.  */
  821.      int truncate_lines;
  822.    Every `#endif' should have a comment, except in the case of short
  823. conditionals (just a few lines) that are not nested.  The comment should
  824. state the condition of the conditional that is ending, *including its
  825. sense*.  `#else' should have a comment describing the condition *and
  826. sense* of the code that follows.  For example:
  827.      #ifdef foo
  828.        ...
  829.      #else /* not foo */
  830.        ...
  831.      #endif /* not foo */
  832. but, by contrast, write the comments this way for a `#ifndef':
  833.      #ifndef foo
  834.        ...
  835.      #else /* foo */
  836.        ...
  837.      #endif /* foo */
  838. File: standards.info,  Node: Syntactic Conventions,  Next: Names,  Prev: Comments,  Up: Top
  839. Clean Use of C Constructs
  840. *************************
  841.    Please explicitly declare all arguments to functions.  Don't omit
  842. them just because they are `int's.
  843.    Declarations of external functions and functions to appear later in
  844. the source file should all go in one place near the beginning of the
  845. file (somewhere before the first function definition in the file), or
  846. else should go in a header file.  Don't put `extern' declarations inside
  847. functions.
  848.    It used to be common practice to use the same local variables (with
  849. names like `tem') over and over for different values within one
  850. function.  Instead of doing this, it is better declare a separate local
  851. variable for each distinct purpose, and give it a name which is
  852. meaningful.  This not only makes programs easier to understand, it also
  853. facilitates optimization by good compilers.  You can also move the
  854. declaration of each local variable into the smallest scope that includes
  855. all its uses.  This makes the program even cleaner.
  856.    Don't use local variables or parameters that shadow global
  857. identifiers.
  858.    Don't declare multiple variables in one declaration that spans lines.
  859. Start a new declaration on each line, instead.  For example, instead of
  860. this:
  861.      int    foo,
  862.             bar;
  863. write either this:
  864.      int foo, bar;
  865. or this:
  866.      int foo;
  867.      int bar;
  868. (If they are global variables, each should have a comment preceding it
  869. anyway.)
  870.    When you have an `if'-`else' statement nested in another `if'
  871. statement, always put braces around the `if'-`else'.  Thus, never write
  872. like this:
  873.      if (foo)
  874.        if (bar)
  875.          win ();
  876.        else
  877.          lose ();
  878. always like this:
  879.      if (foo)
  880.        {
  881.          if (bar)
  882.            win ();
  883.          else
  884.            lose ();
  885.        }
  886.    If you have an `if' statement nested inside of an `else' statement,
  887. either write `else if' on one line, like this,
  888.      if (foo)
  889.        ...
  890.      else if (bar)
  891.        ...
  892. with its `then'-part indented like the preceding `then'-part, or write
  893. the nested `if' within braces like this:
  894.      if (foo)
  895.        ...
  896.      else
  897.        {
  898.          if (bar)
  899.            ...
  900.        }
  901.    Don't declare both a structure tag and variables or typedefs in the
  902. same declaration.  Instead, declare the structure tag separately and
  903. then use it to declare the variables or typedefs.
  904.    Try to avoid assignments inside `if'-conditions.  For example, don't
  905. write this:
  906.      if ((foo = (char *) malloc (sizeof *foo)) == 0)
  907.        fatal ("virtual memory exhausted");
  908. instead, write this:
  909.      foo = (char *) malloc (sizeof *foo);
  910.      if (foo == 0)
  911.        fatal ("virtual memory exhausted");
  912.    Don't make the program ugly to placate `lint'.  Please don't insert
  913. any casts to `void'.  Zero without a cast is perfectly fine as a null
  914. pointer constant.
  915. File: standards.info,  Node: Names,  Next: Using Extensions,  Prev: Syntactic Conventions,  Up: Top
  916. Naming Variables and Functions
  917. ******************************
  918.    Please use underscores to separate words in a name, so that the Emacs
  919. word commands can be useful within them.  Stick to lower case; reserve
  920. upper case for macros and `enum' constants, and for name-prefixes that
  921. follow a uniform convention.
  922.    For example, you should use names like `ignore_space_change_flag';
  923. don't use names like `iCantReadThis'.
  924.    Variables that indicate whether command-line options have been
  925. specified should be named after the meaning of the option, not after
  926. the option-letter.  A comment should state both the exact meaning of
  927. the option and its letter.  For example,
  928.      /* Ignore changes in horizontal whitespace (-b).  */
  929.      int ignore_space_change_flag;
  930.    When you want to define names with constant integer values, use
  931. `enum' rather than `#define'.  GDB knows about enumeration constants.
  932.    Use file names of 14 characters or less, to avoid creating gratuitous
  933. problems on System V.  You can use the program `doschk' to test for
  934. this.  `doschk' also tests for potential name conflicts if the files
  935. were loaded onto an MS-DOS file system--something you may or may not
  936. care about.
  937. File: standards.info,  Node: Using Extensions,  Next: System Functions,  Prev: Names,  Up: Top
  938. Using Non-standard Features
  939. ***************************
  940.    Many GNU facilities that already exist support a number of convenient
  941. extensions over the comparable Unix facilities.  Whether to use these
  942. extensions in implementing your program is a difficult question.
  943.    On the one hand, using the extensions can make a cleaner program.
  944. On the other hand, people will not be able to build the program unless
  945. the other GNU tools are available.  This might cause the program to
  946. work on fewer kinds of machines.
  947.    With some extensions, it might be easy to provide both alternatives.
  948. For example, you can define functions with a "keyword" `INLINE' and
  949. define that as a macro to expand into either `inline' or nothing,
  950. depending on the compiler.
  951.    In general, perhaps it is best not to use the extensions if you can
  952. straightforwardly do without them, but to use the extensions if they
  953. are a big improvement.
  954.    An exception to this rule are the large, established programs (such
  955. as Emacs) which run on a great variety of systems.  Such programs would
  956. be broken by use of GNU extensions.
  957.    Another exception is for programs that are used as part of
  958. compilation: anything that must be compiled with other compilers in
  959. order to bootstrap the GNU compilation facilities.  If these require
  960. the GNU compiler, then no one can compile them without having them
  961. installed already.  That would be no good.
  962.    Since most computer systems do not yet implement ANSI C, using the
  963. ANSI C features is effectively using a GNU extension, so the same
  964. considerations apply.  (Except for ANSI features that we discourage,
  965. such as trigraphs--don't ever use them.)
  966. File: standards.info,  Node: System Functions,  Next: Semantics,  Prev: Using Extensions,  Up: Top
  967. Calling System Functions
  968. ************************
  969.    C implementations differ substantially.  ANSI C reduces but does not
  970. eliminate the incompatibilities; meanwhile, many users wish to compile
  971. GNU software with pre-ANSI compilers.  This chapter gives
  972. recommendations for how to use the more or less standard C library
  973. functions to avoid unnecessary loss of portability.
  974.    * Don't use the value of `sprintf'.  It returns the number of
  975.      characters written on some systems, but not on all systems.
  976.    * Don't declare system functions explicitly.
  977.      Almost any declaration for a system function is wrong on some
  978.      system.  To minimize conflicts, leave it to the system header
  979.      files to declare system functions.  If the headers don't declare a
  980.      function, let it remain undeclared.
  981.      While it may seem unclean to use a function without declaring it,
  982.      in practice this works fine for most system library functions on
  983.      the systems where this really happens.  The problem is only
  984.      theoretical.  By contrast, actual declarations have frequently
  985.      caused actual conflicts.
  986.    * If you must declare a system function, don't specify the argument
  987.      types.  Use an old-style declaration, not an ANSI prototype.  The
  988.      more you specify about the function, the more likely a conflict.
  989.    * In particular, don't unconditionally declare `malloc' or `realloc'.
  990.      Most GNU programs use those functions just once, in functions
  991.      conventionally named `xmalloc' and `xrealloc'.  These functions
  992.      call `malloc' and `realloc', respectively, and check the results.
  993.      Because `xmalloc' and `xrealloc' are defined in your program, you
  994.      can declare them in other files without any risk of type conflict.
  995.      On most systems, `int' is the same length as a pointer; thus, the
  996.      calls to `malloc' and `realloc' work fine.  For the few
  997.      exceptional systems (mostly 64-bit machines), you can use
  998.      *conditionalized* declarations of `malloc' and `realloc'--or put
  999.      these declarations in configuration files specific to those
  1000.      systems.
  1001.    * The string functions require special treatment.  Some Unix systems
  1002.      have a header file `string.h'; other have `strings.h'.  Neither
  1003.      file name is portable.  There are two things you can do: use
  1004.      Autoconf to figure out which file to include, or don't include
  1005.      either file.
  1006.    * If you don't include either strings file, you can't get
  1007.      declarations for the string functions from the header file in the
  1008.      usual way.
  1009.      That causes less of a problem than you might think.  The newer ANSI
  1010.      string functions are off-limits anyway because many systems still
  1011.      don't support them.  The string functions you can use are these:
  1012.           strcpy   strncpy   strcat   strncat
  1013.           strlen   strcmp   strncmp
  1014.           strchr   strrchr
  1015.      The copy and concatenate functions work fine without a declaration
  1016.      as long as you don't use their values.  Using their values without
  1017.      a declaration fails on systems where the width of a pointer
  1018.      differs from the width of `int', and perhaps in other cases.  It
  1019.      is trivial to avoid using their values, so do that.
  1020.      The compare functions and `strlen' work fine without a declaration
  1021.      on most systems, possibly all the ones that GNU software runs on.
  1022.      You may find it necessary to declare them *conditionally* on a few
  1023.      systems.
  1024.      The search functions must be declared to return `char *'.  Luckily,
  1025.      there is no variation in the data type they return.  But there is
  1026.      variation in their names.  Some systems give these functions the
  1027.      names `index' and `rindex'; other systems use the names `strchr'
  1028.      and `strrchr'.  Some systems support both pairs of names, but
  1029.      neither pair works on all systems.
  1030.      You should pick a single pair of names and use it throughout your
  1031.      program.  (Nowadays, it is better to choose `strchr' and
  1032.      `strrchr'.)  Declare both of those names as functions returning
  1033.      `char *'.  On systems which don't support those names, define them
  1034.      as macros in terms of the other pair.  For example, here is what
  1035.      to put at the beginning of your file (or in a header) if you want
  1036.      to use the names `strchr' and `strrchr' throughout:
  1037.           #ifndef HAVE_STRCHR
  1038.           #define strchr index
  1039.           #endif
  1040.           #ifndef HAVE_STRRCHR
  1041.           #define strrchr rindex
  1042.           #endif
  1043.           
  1044.           char *strchr ();
  1045.           char *strrchr ();
  1046.    Here we assume that `HAVE_STRCHR' and `HAVE_STRRCHR' are macros
  1047. defined in systems where the corresponding functions exist.  One way to
  1048. get them properly defined is to use Autoconf.
  1049. File: standards.info,  Node: Semantics,  Next: Errors,  Prev: System Functions,  Up: Top
  1050. Program Behavior for All Programs
  1051. *********************************
  1052.    Avoid arbitrary limits on the length or number of *any* data
  1053. structure, including filenames, lines, files, and symbols, by allocating
  1054. all data structures dynamically.  In most Unix utilities, "long lines
  1055. are silently truncated".  This is not acceptable in a GNU utility.
  1056.    Utilities reading files should not drop NUL characters, or any other
  1057. nonprinting characters *including those with codes above 0177*.  The
  1058. only sensible exceptions would be utilities specifically intended for
  1059. interface to certain types of printers that can't handle those
  1060. characters.
  1061.    Check every system call for an error return, unless you know you
  1062. wish to ignore errors.  Include the system error text (from `perror' or
  1063. equivalent) in *every* error message resulting from a failing system
  1064. call, as well as the name of the file if any and the name of the
  1065. utility.  Just "cannot open foo.c" or "stat failed" is not sufficient.
  1066.    Check every call to `malloc' or `realloc' to see if it returned
  1067. zero.  Check `realloc' even if you are making the block smaller; in a
  1068. system that rounds block sizes to a power of 2, `realloc' may get a
  1069. different block if you ask for less space.
  1070.    In Unix, `realloc' can destroy the storage block if it returns zero.
  1071. GNU `realloc' does not have this bug: if it fails, the original block
  1072. is unchanged.  Feel free to assume the bug is fixed.  If you wish to
  1073. run your program on Unix, and wish to avoid lossage in this case, you
  1074. can use the GNU `malloc'.
  1075.    You must expect `free' to alter the contents of the block that was
  1076. freed.  Anything you want to fetch from the block, you must fetch before
  1077. calling `free'.
  1078.    Use `getopt_long' to decode arguments, unless the argument syntax
  1079. makes this unreasonable.
  1080.    When static storage is to be written in during program execution, use
  1081. explicit C code to initialize it.  Reserve C initialized declarations
  1082. for data that will not be changed.
  1083.    Try to avoid low-level interfaces to obscure Unix data structures
  1084. (such as file directories, utmp, or the layout of kernel memory), since
  1085. these are less likely to work compatibly.  If you need to find all the
  1086. files in a directory, use `readdir' or some other high-level interface.
  1087. These will be supported compatibly by GNU.
  1088.    By default, the GNU system will provide the signal handling
  1089. functions of BSD and of POSIX.  So GNU software should be written to use
  1090. these.
  1091.    In error checks that detect "impossible" conditions, just abort.
  1092. There is usually no point in printing any message.  These checks
  1093. indicate the existence of bugs.  Whoever wants to fix the bugs will have
  1094. to read the source code and run a debugger.  So explain the problem with
  1095. comments in the source.  The relevant data will be in variables, which
  1096. are easy to examine with the debugger, so there is no point moving them
  1097. elsewhere.
  1098. File: standards.info,  Node: Errors,  Next: Libraries,  Prev: Semantics,  Up: Top
  1099. Formatting Error Messages
  1100. *************************
  1101.    Error messages from compilers should look like this:
  1102.      SOURCE-FILE-NAME:LINENO: MESSAGE
  1103.    Error messages from other noninteractive programs should look like
  1104. this:
  1105.      PROGRAM:SOURCE-FILE-NAME:LINENO: MESSAGE
  1106. when there is an appropriate source file, or like this:
  1107.      PROGRAM: MESSAGE
  1108. when there is no relevant source file.
  1109.    In an interactive program (one that is reading commands from a
  1110. terminal), it is better not to include the program name in an error
  1111. message.  The place to indicate which program is running is in the
  1112. prompt or with the screen layout.  (When the same program runs with
  1113. input from a source other than a terminal, it is not interactive and
  1114. would do best to print error messages using the noninteractive style.)
  1115.    The string MESSAGE should not begin with a capital letter when it
  1116. follows a program name and/or filename.  Also, it should not end with a
  1117. period.
  1118.    Error messages from interactive programs, and other messages such as
  1119. usage messages, should start with a capital letter.  But they should not
  1120. end with a period.
  1121. File: standards.info,  Node: Libraries,  Next: Portability,  Prev: Errors,  Up: Top
  1122. Library Behavior
  1123. ****************
  1124.    Try to make library functions reentrant.  If they need to do dynamic
  1125. storage allocation, at least try to avoid any nonreentrancy aside from
  1126. that of `malloc' itself.
  1127.    Here are certain name conventions for libraries, to avoid name
  1128. conflicts.
  1129.    Choose a name prefix for the library, more than two characters long.
  1130. All external function and variable names should start with this prefix.
  1131. In addition, there should only be one of these in any given library
  1132. member.  This usually means putting each one in a separate source file.
  1133.    An exception can be made when two external symbols are always used
  1134. together, so that no reasonable program could use one without the
  1135. other; then they can both go in the same file.
  1136.    External symbols that are not documented entry points for the user
  1137. should have names beginning with `_'.  They should also contain the
  1138. chosen name prefix for the library, to prevent collisions with other
  1139. libraries.  These can go in the same files with user entry points if
  1140. you like.
  1141.    Static functions and variables can be used as you like and need not
  1142. fit any naming convention.
  1143. File: standards.info,  Node: Portability,  Next: User Interfaces,  Prev: Libraries,  Up: Top
  1144. Portability As It Applies to GNU
  1145. ********************************
  1146.    Much of what is called "portability" in the Unix world refers to
  1147. porting to different Unix versions.  This is a secondary consideration
  1148. for GNU software, because its primary purpose is to run on top of one
  1149. and only one kernel, the GNU kernel, compiled with one and only one C
  1150. compiler, the GNU C compiler.  The amount and kinds of variation among
  1151. GNU systems on different cpu's will be like the variation among Berkeley
  1152. 4.3 systems on different cpu's.
  1153.    All users today run GNU software on non-GNU systems.  So supporting a
  1154. variety of non-GNU systems is desirable; simply not paramount.  The
  1155. easiest way to achieve portability to a reasonable range of systems is
  1156. to use Autoconf.  It's unlikely that your program needs to know more
  1157. information about the host machine than Autoconf can provide, simply
  1158. because most of the programs that need such knowledge have already been
  1159. written.
  1160.    It is difficult to be sure exactly what facilities the GNU kernel
  1161. will provide, since it isn't finished yet.  Therefore, assume you can
  1162. use anything in 4.3; just avoid using the format of semi-internal data
  1163. bases (e.g., directories) when there is a higher-level alternative
  1164. (`readdir').
  1165.    You can freely assume any reasonably standard facilities in the C
  1166. language, libraries or kernel, because we will find it necessary to
  1167. support these facilities in the full GNU system, whether or not we have
  1168. already done so.  The fact that there may exist kernels or C compilers
  1169. that lack these facilities is irrelevant as long as the GNU kernel and
  1170. C compiler support them.
  1171.    It remains necessary to worry about differences among cpu types, such
  1172. as the difference in byte ordering and alignment restrictions.  It's
  1173. unlikely that 16-bit machines will ever be supported by GNU, so there
  1174. is no point in spending any time to consider the possibility that an
  1175. int will be less than 32 bits.
  1176.    You can assume that all pointers have the same format, regardless of
  1177. the type they point to, and that this is really an integer.  There are
  1178. some weird machines where this isn't true, but they aren't important;
  1179. don't waste time catering to them.  Besides, eventually we will put
  1180. function prototypes into all GNU programs, and that will probably make
  1181. your program work even on weird machines.
  1182.    Since some important machines (including the 68000) are big-endian,
  1183. it is important not to assume that the address of an `int' object is
  1184. also the address of its least-significant byte.  Thus, don't make the
  1185. following mistake:
  1186.      int c;
  1187.      ...
  1188.      while ((c = getchar()) != EOF)
  1189.              write(file_descriptor, &c, 1);
  1190.    You can assume that it is reasonable to use a meg of memory.  Don't
  1191. strain to reduce memory usage unless it can get to that level.  If your
  1192. program creates complicated data structures, just make them in core and
  1193. give a fatal error if malloc returns zero.
  1194.    If a program works by lines and could be applied to arbitrary
  1195. user-supplied input files, it should keep only a line in memory, because
  1196. this is not very hard and users will want to be able to operate on input
  1197. files that are bigger than will fit in core all at once.
  1198. File: standards.info,  Node: User Interfaces,  Next: Documentation,  Prev: Portability,  Up: Top
  1199. Standards for Command Line Interfaces
  1200. *************************************
  1201.    Please don't make the behavior of a utility depend on the name used
  1202. to invoke it.  It is useful sometimes to make a link to a utility with
  1203. a different name, and that should not change what it does.
  1204.    Instead, use a run time option or a compilation switch or both to
  1205. select among the alternate behaviors.
  1206.    Likewise, please don't make the behavior of the program depend on the
  1207. type of output device it is used with.  Device independence is an
  1208. important principle of the system's design; do not compromise it merely
  1209. to save someone from typing an option now and then.
  1210.    If you think one behavior is most useful when the output is to a
  1211. terminal, and another is most useful when the output is a file or a
  1212. pipe, then it is usually best to make the default behavior the one that
  1213. is useful with output to a terminal, and have an option for the other
  1214. behavior.
  1215.    Compatibility requires certain programs to depend on the type of
  1216. output device.  It would be disastrous if `ls' or `sh' did not do so in
  1217. the way all users expect.  In some of these cases, we supplement the
  1218. program with a preferred alternate version that does not depend on the
  1219. output device type.  For example, we provide a `dir' program much like
  1220. `ls' except that its default output format is always multi-column
  1221. format.
  1222.    It is a good idea to follow the POSIX guidelines for the
  1223. command-line options of a program.  The easiest way to do this is to use
  1224. `getopt' to parse them.  Note that the GNU version of `getopt' will
  1225. normally permit options anywhere among the arguments unless the special
  1226. argument `--' is used.  This is not what POSIX specifies; it is a GNU
  1227. extension.
  1228.    Please define long-named options that are equivalent to the
  1229. single-letter Unix-style options.  We hope to make GNU more user
  1230. friendly this way.  This is easy to do with the GNU function
  1231. `getopt_long'.
  1232.    One of the advantages of long-named options is that they can be
  1233. consistent from program to program.  For example, users should be able
  1234. to expect the "verbose" option of any GNU program which has one, to be
  1235. spelled precisely `--verbose'.  To achieve this uniformity, look at the
  1236. table of common long-option names when you choose the option names for
  1237. your program.  The table appears below.
  1238.    If you use names not already in the table, please send
  1239. `gnu@prep.ai.mit.edu' a list of them, with their meanings, so we can
  1240. update the table.
  1241.    It is usually a good idea for file names given as ordinary arguments
  1242. to be input files only; any output files would be specified using
  1243. options (preferably `-o').  Even if you allow an output file name as an
  1244. ordinary argument for compatibility, try to provide a suitable option
  1245. as well.  This will lead to more consistency among GNU utilities, so
  1246. that there are fewer idiosyncracies for users to remember.
  1247.    Programs should support an option `--version' which prints the
  1248. program's version number on standard output and exits successfully, and
  1249. an option `--help' which prints option usage information on standard
  1250. output and exits successfully.  These options should inhibit the normal
  1251. function of the command; they should do nothing except print the
  1252. requested information.
  1253. `auto-check'
  1254.      `-a' in `recode'.
  1255. `auto-reference'
  1256.      `-A' in `ptx'.
  1257. `after-date'
  1258.      `-N' in `tar'.
  1259. `all'
  1260.      `-a' in `du', `ls', `nm', `stty', `uname', and `unexpand'.
  1261. `all-text'
  1262.      `-a' in `diff'.
  1263. `almost-all'
  1264.      `-A' in `ls'.
  1265. `append'
  1266.      `-a' in `etags', `tee', `time'; `-r' in `tar'.
  1267. `archive'
  1268.      `-a' in `cp'.
  1269. `arglength'
  1270.      `-l' in `m4'.
  1271. `ascii'
  1272.      `-a' in `diff'.
  1273. `assume-new'
  1274.      `-W' in Make.
  1275. `assume-old'
  1276.      `-o' in Make.
  1277. `backward-search'
  1278.      `-B' in etags.
  1279. `batch'
  1280.      Used in GDB.
  1281. `baud'
  1282.      Used in GDB.
  1283. `before'
  1284.      `-b' in `tac'.
  1285. `binary'
  1286.      `-b' in `cpio' and `diff'.
  1287. `block-size'
  1288.      Used in `cpio' and `tar'.
  1289. `blocks'
  1290.      `-b' in `head' and `tail'.
  1291. `break-file'
  1292.      `-b' in `ptx'.
  1293. `brief'
  1294.      Used in various programs to make output shorter.
  1295. `bytes'
  1296.      `-c' in `head', `split', and `tail'.
  1297. `c++'
  1298.      `-C' in `etags'.
  1299. `catenate'
  1300.      `-A' in `tar'.
  1301.      Used in various programs to specify the directory to use.
  1302. `changes'
  1303.      `-c' in `chgrp' and `chown'.
  1304. `classify'
  1305.      `-F' in `ls'.
  1306. `colons'
  1307.      `-c' in `recode'.
  1308. `command'
  1309.      `-c' in `su'; `-x' in GDB.
  1310. `compare'
  1311.      `-d' in `tar'.
  1312. `compress'
  1313.      `-Z' in `tar'.
  1314. `concatenate'
  1315.      `-A' in `tar'.
  1316. `confirmation'
  1317.      `-w' in `tar'.
  1318. `context'
  1319.      Used in `diff'.
  1320. `copyright'
  1321.      `-C' in `ptx' and `recode'.
  1322. `core'
  1323.      Used in GDB.
  1324. `count'
  1325.      `-q' in `who'.
  1326. `count-links'
  1327.      `-l' in `du'.
  1328. `create'
  1329.      Used in `tar' and `cpio'.
  1330. `cxref'
  1331.      `-x' in `etags'.
  1332. `date'
  1333.      `-d' in `touch'.
  1334. `debug'
  1335.      `-d' in Make and `m4'; `-t' in Bison.
  1336. `define'
  1337.      `-D' in `m4'.
  1338. `defines'
  1339.      `-d' in Bison and `etags'.
  1340. `delete'
  1341.      `-D' in `tar'.
  1342. `dereference'
  1343.      `-L' in `chgrp', `chown', `cpio', `du', `ls', and `tar'.
  1344. `dereference-args'
  1345.      `-D' in `du'.
  1346. `diacritics'
  1347.      `-d' in `recode'.
  1348. `dictionary-order'
  1349.      `-d' in `look'.
  1350. `diff'
  1351.      `-d' in `tar'.
  1352. `digits'
  1353.      `-n' in `csplit'.
  1354. `directory'
  1355.      Specify the directory to use, in various programs.  In `ls', it
  1356.      means to show directories themselves rather than their contents.
  1357.      In `rm' and `ln', it means to not treat links to directories
  1358.      specially.
  1359. `discard-all'
  1360.      `-x' in `strip'.
  1361. `discard-locals'
  1362.      `-X' in `strip'.
  1363. `diversions'
  1364.      `-N' in `m4'.
  1365. `dry-run'
  1366.      `-n' in Make.
  1367.      `-e' in `diff'.
  1368. `elide-empty-files'
  1369.      `-z' in `csplit'.
  1370. `entire-new-file'
  1371.      `-N' in `diff'.
  1372. `environment-overrides'
  1373.      `-e' in Make.
  1374. `eof'
  1375.      `-e' in `xargs'.
  1376. `epoch'
  1377.      Used in GDB.
  1378. `error-limit'
  1379.      Used in Makeinfo.
  1380. `error-output'
  1381.      `-o' in `m4'.
  1382. `escape'
  1383.      `-b' in `ls'.
  1384. `exclude-from'
  1385.      `-X' in `tar'.
  1386. `exec'
  1387.      Used in GDB.
  1388. `exit'
  1389.      `-x' in `xargs'.
  1390. `expand-tabs'
  1391.      `-t' in `diff'.
  1392. `expression'
  1393.      `-e' in `sed'.
  1394. `extern-only'
  1395.      `-g' in `nm'.
  1396. `extract'
  1397.      `-i' in `cpio'; `-x' in `tar'.
  1398. `faces'
  1399.      `-f' in `finger'.
  1400. `fast'
  1401.      `-f' in `su'.
  1402. `file'
  1403.      `-f' in `info', Make, `mt', and `tar'; `-n' in `sed'; `-r' in
  1404.      `touch'.
  1405. `file-prefix'
  1406.      `-b' in Bison.
  1407. `file-type'
  1408.      `-F' in `ls'.
  1409. `files-from'
  1410.      `-T' in `tar'.
  1411. `fill-column'
  1412.      Used in Makeinfo.
  1413. `flag-truncation'
  1414.      `-F' in `ptx'.
  1415. `fixed-output-files'
  1416.      `-y' in Bison.
  1417. `follow'
  1418.      `-f' in `tail'.
  1419. `footnote-style'
  1420.      Used in Makeinfo.
  1421. `force'
  1422.      `-f' in `cp', `ln', `mv', and `rm'.
  1423. `format'
  1424.      Used in `ls', `time', and `ptx'.
  1425. `forward-search'
  1426.      `-F' in `etags'.
  1427. `fullname'
  1428.      Used in GDB.
  1429. `gap-size'
  1430.      `-g' in `ptx'.
  1431. `get'
  1432.      `-x' in `tar'.
  1433. `graphic'
  1434.      `-i' in `ul'.
  1435. `graphics'
  1436.      `-g' in `recode'.
  1437. `group'
  1438.      `-g' in `install'.
  1439. `gzip'
  1440.      `-z' in `tar'.
  1441. `hashsize'
  1442.      `-H' in `m4'.
  1443. `header'
  1444.      `-h' in `objdump' and `recode'
  1445. `heading'
  1446.      `-H' in `who'.
  1447. `help'
  1448.      Used to ask for brief usage information.
  1449. `hide-control-chars'
  1450.      `-q' in `ls'.
  1451. `idle'
  1452.      `-u' in `who'.
  1453. `ifdef'
  1454.      `-D' in `diff'.
  1455. `ignore'
  1456.      `-I' in `ls'; `-x' in `recode'.
  1457. `ignore-all-space'
  1458.      `-w' in `diff'.
  1459. `ignore-backups'
  1460.      `-B' in `ls'.
  1461. `ignore-blank-lines'
  1462.      `-B' in `diff'.
  1463. `ignore-case'
  1464.      `-f' in `look' and `ptx'; `-i' in `diff'.
  1465. `ignore-errors'
  1466.      `-i' in Make.
  1467. `ignore-file'
  1468.      `-i' in `ptx'.
  1469. `ignore-indentation'
  1470.      `-S' in `etags'.
  1471. `ignore-init-file'
  1472.      `-f' in Oleo.
  1473. `ignore-interrupts'
  1474.      `-i' in `tee'.
  1475. `ignore-matching-lines'
  1476.      `-I' in `diff'.
  1477. `ignore-space-change'
  1478.      `-b' in `diff'.
  1479. `ignore-zeros'
  1480.      `-i' in `tar'.
  1481. `include'
  1482.      `-i' in `etags'; `-I' in `m4'.
  1483. `include-dir'
  1484.      `-I' in Make.
  1485. `incremental'
  1486.      `-G' in `tar'.
  1487. `info'
  1488.      `-i', `-l', and `-m' in Finger.
  1489. `initial'
  1490.      `-i' in `expand'.
  1491. `initial-tab'
  1492.      `-T' in `diff'.
  1493. `inode'
  1494.      `-i' in `ls'.
  1495. `interactive'
  1496.      `-i' in `cp', `ln', `mv', `rm'; `-e' in `m4'; `-p' in `xargs';
  1497.      `-w' in `tar'.
  1498. `jobs'
  1499.      `-j' in Make.
  1500. `just-print'
  1501.      `-n' in Make.
  1502. `keep-going'
  1503.      `-k' in Make.
  1504. `keep-files'
  1505.      `-k' in `csplit'.
  1506. `kilobytes'
  1507.      `-k' in `du' and `ls'.
  1508. `line-bytes'
  1509.      `-C' in `split'.
  1510. `lines'
  1511.      Used in `split', `head', and `tail'.
  1512. `link'
  1513.      `-l' in `cpio'.
  1514. `list'
  1515.      `-t' in `cpio'; `-l' in `recode'.
  1516. `list'
  1517.      `-t' in `tar'.
  1518. `literal'
  1519.      `-N' in `ls'.
  1520. `load-average'
  1521.      `-l' in Make.
  1522. `login'
  1523.      Used in `su'.
  1524. `machine'
  1525.      No listing of which programs already use this; someone should
  1526.      check to see if any actually do and tell `gnu@prep.ai.mit.edu'.
  1527. `macro-name'
  1528.      `-M' in `ptx'.
  1529. `mail'
  1530.      `-m' in `hello' and `uname'.
  1531. `make-directories'
  1532.      `-d' in `cpio'.
  1533. `makefile'
  1534.      `-f' in Make.
  1535. `mapped'
  1536.      Used in GDB.
  1537. `max-args'
  1538.      `-n' in `xargs'.
  1539. `max-chars'
  1540.      `-n' in `xargs'.
  1541. `max-lines'
  1542.      `-l' in `xargs'.
  1543. `max-load'
  1544.      `-l' in Make.
  1545. `max-procs'
  1546.      `-P' in `xargs'.
  1547. `mesg'
  1548.      `-T' in `who'.
  1549. `message'
  1550.      `-T' in `who'.
  1551. `minimal'
  1552.      `-d' in `diff'.
  1553. `mode'
  1554.      `-m' in `install', `mkdir', and `mkfifo'.
  1555. `modification-time'
  1556.      `-m' in `tar'.
  1557. `multi-volume'
  1558.      `-M' in `tar'.
  1559. `name-prefix'
  1560.      `-a' in Bison.
  1561. `new-file'
  1562.      `-W' in Make.
  1563. `no-builtin-rules'
  1564.      `-r' in Make.
  1565. `no-create'
  1566.      `-c' in `touch'.
  1567. `no-defines'
  1568.      `-D' in `etags'.
  1569. `no-dereference'
  1570.      `-d' in `cp'.
  1571. `no-keep-going'
  1572.      `-S' in Make.
  1573. `no-lines'
  1574.      `-l' in Bison.
  1575. `no-prof'
  1576.      `-e' in `gprof'.
  1577. `no-sort'
  1578.      `-p' in `nm'.
  1579. `no-split'
  1580.      Used in Makeinfo.
  1581. `no-static'
  1582.      `-a' in `gprof'.
  1583. `no-time'
  1584.      `-E' in `gprof'.
  1585. `no-validate'
  1586.      Used in Makeinfo.
  1587. `no-warn'
  1588.      Used in various programs to inhibit warnings.
  1589. `node'
  1590.      `-n' in `info'.
  1591. `nodename'
  1592.      `-n' in `uname'.
  1593. `nonmatching'
  1594.      `-f' in `cpio'.
  1595. `nstuff'
  1596.      `-n' in `objdump'.
  1597. `null'
  1598.      `-0' in `xargs'.
  1599. `number'
  1600.      `-n' in `cat'.
  1601. `number-nonblank'
  1602.      `-b' in `cat'.
  1603. `numeric-sort'
  1604.      `-n' in `nm'.
  1605. `numeric-uid-gid'
  1606.      `-n' in `cpio' and `ls'.
  1607.      Used in GDB.
  1608. `old-archive'
  1609.      `-o' in `tar'.
  1610. `old-file'
  1611.      `-o' in Make.
  1612. `one-file-system'
  1613.      `-l' in `tar', `cp', and `du'.
  1614. `only-file'
  1615.      `-o' in `ptx'.
  1616. `only-prof'
  1617.      `-f' in `gprof'.
  1618. `only-time'
  1619.      `-F' in `gprof'.
  1620. `output'
  1621.      In various programs, specify the output file name.
  1622. `override'
  1623.      `-o' in `rm'.
  1624. `owner'
  1625.      `-o' in `install'.
  1626. `paginate'
  1627.      `-l' in `diff'.
  1628. `paragraph-indent'
  1629.      Used in Makeinfo.
  1630. `parents'
  1631.      `-p' in `mkdir' and `rmdir'.
  1632. `pass-all'
  1633.      `-p' in `ul'.
  1634. `pass-through'
  1635.      `-p' in `cpio'.
  1636. `port'
  1637.      `-P' in `finger'.
  1638. `portability'
  1639.      `-c' in `cpio' and `tar'.
  1640. `prefix-builtins'
  1641.      `-P' in `m4'.
  1642. `prefix'
  1643.      `-f' in `csplit'.
  1644. `preserve'
  1645.      Used in `tar' and `cp'.
  1646. `preserve-environment'
  1647.      `-p' in `su'.
  1648. `preserve-modification-time'
  1649.      `-m' in `cpio'.
  1650. `preserve-order'
  1651.      `-s' in `tar'.
  1652. `preserve-permissions'
  1653.      `-p' in `tar'.
  1654. `print'
  1655.      `-l' in `diff'.
  1656. `print-chars'
  1657.      `-L' in `cmp'.
  1658. `print-data-base'
  1659.      `-p' in Make.
  1660. `print-directory'
  1661.      `-w' in Make.
  1662. `print-file-name'
  1663.      `-o' in `nm'.
  1664. `print-symdefs'
  1665.      `-s' in `nm'.
  1666. `question'
  1667.      `-q' in Make.
  1668. `quiet'
  1669.      Used in many programs to inhibit the usual output.  *Note:* every
  1670.      program accepting `--quiet' should accept `--silent' as a synonym.
  1671. `quote-name'
  1672.      `-Q' in `ls'.
  1673. `rcs'
  1674.      `-n' in `diff'.
  1675. `read-full-blocks'
  1676.      `-B' in `tar'.
  1677. `readnow'
  1678.      Used in GDB.
  1679. `recon'
  1680.      `-n' in Make.
  1681. `record-number'
  1682.      `-R' in `tar'.
  1683. `recursive'
  1684.      Used in `chgrp', `chown', `cp', `ls', `diff', and `rm'.
  1685. `reference-limit'
  1686.      Used in Makeinfo.
  1687. `references'
  1688.      `-r' in `ptx'.
  1689. `regex'
  1690.      `-r' in `tac'.
  1691. `release'
  1692.      `-r' in `uname'.
  1693. `relocation'
  1694.      `-r' in `objdump'.
  1695. `rename'
  1696.      `-r' in `cpio'.
  1697. `replace'
  1698.      `-i' in `xargs'.
  1699. `report-identical-files'
  1700.      `-s' in `diff'.
  1701. `reset-access-time'
  1702.      `-a' in `cpio'.
  1703. `reverse'
  1704.      `-r' in `ls' and `nm'.
  1705. `reversed-ed'
  1706.      `-f' in `diff'.
  1707. `right-side-defs'
  1708.      `-R' in `ptx'.
  1709. `same-order'
  1710.      `-s' in `tar'.
  1711. `same-permissions'
  1712.      `-p' in `tar'.
  1713. `save'
  1714.      `-g' in `stty'.
  1715.      Used in GDB.
  1716. `sentence-regexp'
  1717.      `-S' in `ptx'.
  1718. `separate-dirs'
  1719.      `-S' in `du'.
  1720. `separator'
  1721.      `-s' in `tac'.
  1722. `sequence'
  1723.      Used by `recode' to chose files or pipes for sequencing passes.
  1724. `shell'
  1725.      `-s' in `su'.
  1726. `show-all'
  1727.      `-A' in `cat'.
  1728. `show-c-function'
  1729.      `-p' in `diff'.
  1730. `show-ends'
  1731.      `-E' in `cat'.
  1732. `show-function-line'
  1733.      `-F' in `diff'.
  1734. `show-tabs'
  1735.      `-T' in `cat'.
  1736. `silent'
  1737.      Used in many programs to inhibit the usual output.  *Note:* every
  1738.      program accepting `--silent' should accept `--quiet' as a synonym.
  1739. `size'
  1740.      `-s' in `ls'.
  1741. `sort'
  1742.      Used in `ls'.
  1743. `sparse'
  1744.      `-S' in `tar'.
  1745. `speed-large-files'
  1746.      `-H' in `diff'.
  1747. `squeeze-blank'
  1748.      `-s' in `cat'.
  1749. `starting-file'
  1750.      Used in `tar' and `diff' to specify which file within a directory
  1751.      to start processing with.
  1752. `stop'
  1753.      `-S' in Make.
  1754. `strict'
  1755.      `-s' in `recode'.
  1756. `strip'
  1757.      `-s' in `install'.
  1758. `strip-all'
  1759.      `-s' in `strip'.
  1760. `strip-debug'
  1761.      `-S' in `strip'.
  1762. `suffix'
  1763.      `-S' in `cp', `ln', `mv'.
  1764. `suffix-format'
  1765.      `-b' in `csplit'.
  1766. `sum'
  1767.      `-s' in `gprof'.
  1768. `summarize'
  1769.      `-s' in `du'.
  1770. `symbolic'
  1771.      `-s' in `ln'.
  1772. `symbols'
  1773.      Used in GDB and `objdump'.
  1774. `synclines'
  1775.      `-s' in `m4'.
  1776. `sysname'
  1777.      `-s' in `uname'.
  1778. `tabs'
  1779.      `-t' in `expand' and `unexpand'.
  1780. `tabsize'
  1781.      `-T' in `ls'.
  1782. `terminal'
  1783.      `-T' in `tput' and `ul'.
  1784. `text'
  1785.      `-a' in `diff'.
  1786. `time'
  1787.      Used in `ls' and `touch'.
  1788. `to-stdout'
  1789.      `-O' in `tar'.
  1790. `total'
  1791.      `-c' in `du'.
  1792. `touch'
  1793.      `-t' in Make, `ranlib', and `recode'.
  1794. `trace'
  1795.      `-t' in `m4'.
  1796. `traditional'
  1797.      `-t' in `hello'; `-G' in `m4' and `ptx'.
  1798. `tty'
  1799.      Used in GDB.
  1800. `typedefs'
  1801.      `-t' in `etags'.
  1802. `typedefs-and-c++'
  1803.      `-T' in `etags'.
  1804. `typeset-mode'
  1805.      `-t' in `ptx'.
  1806. `uncompress'
  1807.      `-z' in `tar'.
  1808. `unconditional'
  1809.      `-u' in `cpio'.
  1810. `undefine'
  1811.      `-U' in `m4'.
  1812. `undefined-only'
  1813.      `-u' in `nm'.
  1814. `update'
  1815.      `-u' in `cp', `etags', `mv', `tar'.
  1816. `verbose'
  1817.      Print more information about progress.  Many programs support this.
  1818. `verify'
  1819.      `-W' in `tar'.
  1820. `version'
  1821.      Print the version number.
  1822. `version-control'
  1823.      `-V' in `cp', `ln', `mv'.
  1824. `vgrind'
  1825.      `-v' in `etags'.
  1826. `volume'
  1827.      `-V' in `tar'.
  1828. `what-if'
  1829.      `-W' in Make.
  1830. `width'
  1831.      `-w' in `ls' and `ptx'.
  1832. `word-regexp'
  1833.      `-W' in `ptx'.
  1834. `writable'
  1835.      `-T' in `who'.
  1836. `zeros'
  1837.      `-z' in `gprof'.
  1838. File: standards.info,  Node: Documentation,  Next: Releases,  Prev: User Interfaces,  Up: Top
  1839. Documenting Programs
  1840. ********************
  1841.    Please use Texinfo for documenting GNU programs.  See the Texinfo
  1842. manual, either the hardcopy or the version in the GNU Emacs Info
  1843. subsystem (`C-h i').  See existing GNU Texinfo files (e.g., those under
  1844. the `man/' directory in the GNU Emacs distribution) for examples.
  1845.    The title page of the manual should state the version of the program
  1846. which the manual applies to.  The Top node of the manual should also
  1847. contain this information.  If the manual is changing more frequently
  1848. than or independent of the program, also state a version number for the
  1849. manual in both of these places.
  1850.    The manual should document all command-line arguments and all
  1851. commands.  It should give examples of their use.  But don't organize
  1852. the manual as a list of features.  Instead, organize it by the concepts
  1853. a user will have before reaching that point in the manual.  Address the
  1854. goals that a user will have in mind, and explain how to accomplish
  1855. them.  Don't use Unix man pages as a model for how to write GNU
  1856. documentation; they are a bad example to follow.
  1857.    The manual should have a node named `PROGRAM Invocation' or
  1858. `Invoking PROGRAM', where PROGRAM stands for the name of the program
  1859. being described, as you would type it in the shell to run the program.
  1860. This node (together with its subnodes, if any) should describe the
  1861. program's command line arguments and how to run it (the sort of
  1862. information people would look in a man page for).  Start with an
  1863. `@example' containing a template for all the options and arguments that
  1864. the program uses.
  1865.    Alternatively, put a menu item in some menu whose item name fits one
  1866. of the above patterns.  This identifies the node which that item points
  1867. to as the node for this purpose, regardless of the node's actual name.
  1868.    There will be automatic features for specifying a program name and
  1869. quickly reading just this part of its manual.
  1870.    If one manual describes several programs, it should have such a node
  1871. for each program described.
  1872.    In addition to its manual, the package should have a file named
  1873. `NEWS' which contains a list of user-visible changes worth mentioning.
  1874. In each new release, add items to the front of the file and identify
  1875. the version they pertain to.  Don't discard old items; leave them in
  1876. the file after the newer items.  This way, a user upgrading from any
  1877. previous version can see what is new.
  1878.    If the `NEWS' file gets very long, move some of the older items into
  1879. a file named `ONEWS' and put a note at the end referring the user to
  1880. that file.
  1881.    Please do not use the term "pathname" that is used in Unix
  1882. documentation; use "file name" (two words) instead.  We use the term
  1883. "path" only for search paths, which are lists of file names.
  1884.    It is ok to supply a man page for the program as well as a Texinfo
  1885. manual if you wish to.  But keep in mind that supporting a man page
  1886. requires continual effort, each time the program is changed.  Any time
  1887. you spend on the man page is time taken away from more useful things you
  1888. could contribute.
  1889.    Thus, even if a user volunteers to donate a man page, you may find
  1890. this gift costly to accept.  Unless you have time on your hands, it may
  1891. be better to refuse the man page unless the same volunteer agrees to
  1892. take full responsibility for maintaining it--so that you can wash your
  1893. hands of it entirely.  If the volunteer ceases to do the job, then
  1894. don't feel obliged to pick it up yourself; it may be better to withdraw
  1895. the man page until another volunteer offers to carry on with it.
  1896.    Alternatively, if you expect the discrepancies to be small enough
  1897. that the man page remains useful, put a prominent note near the
  1898. beginning of the man page explaining that you don't maintain it and
  1899. that the Texinfo manual is more authoritative, and describing how to
  1900. access the Texinfo documentation.
  1901. File: standards.info,  Node: Releases,  Prev: Documentation,  Up: Top
  1902. Making Releases
  1903. ***************
  1904.    Package the distribution of Foo version 69.96 in a gzipped tar file
  1905. named `foo-69.96.tar.gz'.  It should unpack into a subdirectory named
  1906. `foo-69.96'.
  1907.    Building and installing the program should never modify any of the
  1908. files contained in the distribution.  This means that all the files
  1909. that form part of the program in any way must be classified into "source
  1910. files" and "non-source files".  Source files are written by humans and
  1911. never changed automatically; non-source files are produced from source
  1912. files by programs under the control of the Makefile.
  1913.    Naturally, all the source files must be in the distribution.  It is
  1914. okay to include non-source files in the distribution, provided they are
  1915. up-to-date and machine-independent, so that building the distribution
  1916. normally will never modify them.  We commonly include non-source files
  1917. produced by Bison, Lex, TeX, and Makeinfo; this helps avoid unnecessary
  1918. dependencies between our distributions, so that users can install
  1919. whichever packages they want to install.
  1920.    Non-source files that might actually be modified by building and
  1921. installing the program should *never* be included in the distribution.
  1922. So if you do distribute non-source files, always make sure they are up
  1923. to date when you make a new distribution.
  1924.    Make sure that the directory into which the distribution unpacks (as
  1925. well as any subdirectories) are all world-writable (octal mode 777).
  1926. This is so that old versions of `tar' which preserve the ownership and
  1927. permissions of the files from the tar archive will be able to extract
  1928. all the files even if the user is unprivileged.
  1929.    Make sure that all the files in the distribution are world-readable.
  1930.    Make sure that no file name in the distribution is more than 14
  1931. characters long.  Likewise, no file created by building the program
  1932. should have a name longer than 14 characters.  The reason for this is
  1933. that some systems adhere to a foolish interpretation of the POSIX
  1934. standard, and refuse to open a longer name, rather than truncating as
  1935. they did in the past.
  1936.    Don't include any symbolic links in the distribution itself.  If the
  1937. tar file contains symbolic links, then people cannot even unpack it on
  1938. systems that don't support symbolic links.  Also, don't use multiple
  1939. names for one file in different directories, because certain file
  1940. systems cannot handle this and that prevents unpacking the distribution.
  1941.    Try to make sure that all the file names will be unique on MS-DOG.  A
  1942. name on MS-DOG consists of up to 8 characters, optionally followed by a
  1943. period and up to three characters.  MS-DOG will truncate extra
  1944. characters both before and after the period.  Thus, `foobarhacker.c'
  1945. and `foobarhacker.o' are not ambiguous; they are truncated to
  1946. `foobarha.c' and `foobarha.o', which are distinct.
  1947.    Include in your distribution a copy of the `texinfo.tex' you used to
  1948. test print any `*.texinfo' files.
  1949.    Likewise, if your program uses small GNU software packages like
  1950. regex, getopt, obstack, or termcap, include them in the distribution
  1951. file.  Leaving them out would make the distribution file a little
  1952. smaller at the expense of possible inconvenience to a user who doesn't
  1953. know what other files to get.
  1954. Tag Table:
  1955. Node: Top
  1956. Node: Reading Non-Free Code
  1957. Node: Contributions
  1958. Node: Change Logs
  1959. Node: Compatibility
  1960. Node: Makefile Conventions
  1961. 10728
  1962. Node: Makefile Basics
  1963. 11085
  1964. Node: Utilities in Makefiles
  1965. 12976
  1966. Node: Standard Targets
  1967. 14412
  1968. Node: Command Variables
  1969. 21521
  1970. Node: Directory Variables
  1971. 24351
  1972. Node: Configuration
  1973. 30823
  1974. Node: Source Language
  1975. 37847
  1976. Node: Formatting
  1977. 38977
  1978. Node: Comments
  1979. 42267
  1980. Node: Syntactic Conventions
  1981. 45053
  1982. Node: Names
  1983. 47945
  1984. Node: Using Extensions
  1985. 49235
  1986. Node: System Functions
  1987. 50976
  1988. Node: Semantics
  1989. 55779
  1990. Node: Errors
  1991. 58745
  1992. Node: Libraries
  1993. 59948
  1994. Node: Portability
  1995. 61172
  1996. Node: User Interfaces
  1997. 64459
  1998. Node: Documentation
  1999. 79289
  2000. Node: Releases
  2001. 83223
  2002. End Tag Table
  2003.